//
//  SettingViewController.swift
//  visionos_test_demo
//
//  Created by 3tee on 2024/7/31.
//

import UIKit

protocol SettingViewControllerDelegate :AnyObject{
    func reInitEng(url: String)
}

class SettingViewController: UIViewController {

    weak var delegate: SettingViewControllerDelegate?

    @IBOutlet weak var serverTf: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        if let serverUrl = UserDefaults.standard.string(forKey: K.urlKey) {
            serverTf.text = serverUrl
        }else{
            serverTf.text = K.url
        }
       
        // Do any additional setup after loading the view.
    }

    @IBAction func saveClicked(_ sender: UIButton) {
        //AlertTool.alertShow("⚠️⚠️⚠️⚠️功能开发中。。。。⚠️⚠️⚠️⚠️", alertVC: self)
        UserDefaults.standard.setValue(serverTf.text, forKey: K.urlKey)
        UserDefaults.standard.synchronize()
        self.delegate?.reInitEng(url: serverTf.text!)
        self.navigationController?.popViewController(animated: true)
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
